﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hotel.Vendor.InterfacePlatformManage.Business.HTicketBusiness;
using Hotel.Vendor.InterfacePlatformManage.Entity.HTicketEntity;
using Hotel.Vendor.InterfacePlatformManage.OfflineSite.Page;
using System.Text;

namespace HTicket
{
    public partial class History : System.Web.UI.Page  //HTicketPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //string taskID = Request.QueryString["taskID"];
            //if (!string.IsNullOrEmpty(taskID))
            //{
            //    this.hiddenTaskID.Value = taskID;
            //    BindTreeView();
            //    BindHistory(taskID);
            //    this.lblLogList.Text = ShowHistory(taskID);
            //}
        }

        ///// <summary>
        ///// 根据TaskID绑定回复历史记录
        ///// </summary>
        ///// <param name="taskID"></param>
        //protected void BindHistory(string taskID)
        //{
        //    TaskSearchConditionEntity entity = new TaskSearchConditionEntity();
        //    entity.TaskID = taskID;
        //    entity.GroupID = this.UserInfo.GroupInfo.GroupID;
        //    var list = HotelInterfaceTaskListProcessBusiness.GeTaskContentByTaskID(entity);

        //    if (list.Count > 0)
        //    {
        //        this.ddlProject.Items.Add(new ListItem { Text = list[0].ProjectName, Value = list[0].ProjectID.ToString() });
        //        this.ddlProcess.SelectedValue = list[0].State.ToString();
        //        this.ddlImportance.SelectedValue = list[0].Importance;
        //        this.lblEndDate.Text = list[0].HopeTime;
        //        this.lblSubject.Text = list[0].Subject;
        //        this.ddlHandleMan.SelectedValue = list[0].HandleMan;
        //    }
        //}

        ///// <summary>
        ///// 初始化处理人
        ///// </summary>
        ///// <param name="groupID"></param>
        //protected void BindTreeView()
        //{
        //    var list = HotelInterfaceTaskListProcessBusiness.GetUserInfoByGroupId(this.UserInfo.GroupInfo.GroupID);

        //    var eidList = list.Select(item => { return item.Eid; }) as List<string>;

        //    list.ForEach(item =>
        //    {
        //        //添加经理
        //        if (string.IsNullOrEmpty(item.ParentID))
        //        {
        //            this.ddlHandleMan.Items.Add(new ListItem
        //            {
        //                Value = item.Eid,
        //                Text = item.UserName
        //            });
        //        }
        //    });


        //    //添加开发人员
        //    list.ForEach(item =>
        //    {
        //        if (!string.IsNullOrEmpty(item.ParentID))
        //        {
        //            this.ddlHandleMan.Items.Add(new ListItem
        //            {
        //                Value = item.Eid,
        //                Text = "  ------ " + item.UserName
        //            });
        //        }
        //    });
        //}

        ////历史记录
        //public string ShowHistory(string taskID)
        //{
        //    TaskSearchConditionEntity searchEntity = new TaskSearchConditionEntity
        //    {
        //        GroupID = this.UserInfo.GroupInfo.GroupID,
        //        TaskID = taskID
        //    };

        //    var items = HotelInterfaceTaskListProcessBusiness.GeTaskContentByTaskID(searchEntity);

        //    StringBuilder str = new StringBuilder();
        //    str.AppendFormat("{0}<br><hr>", items.First().Subject);


        //    foreach (var item in items)
        //    {
        //        string dir = "";// item.Flag.ToLower() == "q" ? "question" : "answer";
        //        string userName = this.GetLoginUserInfoByEID(new List<string> { item.Eid }).Name;

        //        if (item.Flag.ToLower() == "q")
        //        {
        //            dir = "question";
        //        }
        //        else
        //        {
        //            if (item.Content.IndexOf("Tickets系统提示") > -1)
        //                dir = "end";
        //            else
        //                dir = "answer";
        //        }
        //        str.AppendFormat(@"<div class=""{3}""><b class=""b1""></b><b class=""b2""></b><b class=""b3""></b><b class=""b4""></b><div class=""boxcontent""><span style='font-weight:bold'>{0}:  {1}</span><br>    {2}<br>回复人:  <a eid={5}>{4}</a></div><b class=""b4b""></b><b class=""b3b""></b><b class=""b2b""></b><b class=""b1b""></b></div>", item.Flag.ToLower() == "q" ? "Q" : "A", item.DataChange_LastTime.ToString(), item.Content, dir, userName, item.Eid);
        //    }
        //    return str.ToString();
        //}
    }
}